<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

  <%
  
  	Option explicit
  
	  if request.form("cancel") <> ""  then
			response.redirect("menu.aspx")	  
	  End if
  
'	Page called by itself, it updates or inserts a record then goes back to the main list
	if request.form("update") <> ""  then

		call MakeConn(objConn, DATABASE)	
		call MakeRs_add(objRs,objConn, "Select  * from persons where userid=" & FormatStringDb(session("UserId")) )

		if request("password1") =  request("password2") and len(trim(request("password2"))) <> 0 Then
' 			aggiorna password
			objRS("password") = request("password1")
			objRs.update
			response.redirect("menu.aspx?msgtype=I&msgno=" & MSGNO_PASSWORD_CHANGED)
		End if
		
	End If		
		
%>

<html><!-- InstanceBegin template="/Templates/common.dwt" codeOutsideHTMLIsLocked="false" -->
<!--#include virtual="/timereport/include/auth.asp" -->
<!--#include virtual="/timereport/include/common.asp" -->

<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Modifica password</title>
<!-- InstanceEndEditable --> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" -->
<link href="include/commoncss.asp" rel="stylesheet" type="text/css">
<!-- InstanceEndEditable -->
</head>

<SCRIPT language=JavaScript src= "/timereport/include/menu/menu_array.js" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript src= "/timereport/include/menu/mmenu.js" type=text/javascript></SCRIPT>

<body>
<table width="760" border="0" align="left" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="30" class="BarraTop"><div align="right">Utente: <%= session("UserName") %> 
      </div></td>
  </tr>
  <tr>
    <td height="30">&nbsp;</td>
  </tr>
  <tr> <!-- InstanceBeginEditable name="principale" -->   
    <td >
        <table width="50%" border="0" align="center" cellpadding="0" cellspacing="0" class="TabellaBianca">
        <tr>

<%
'		Error message if inserted password don't match, the error is displayed together with the
'		error icon within the table line

		Dim strErrMsg

		if request.form("update") <> "" then
'			password1 and 2 don't match
			if request("oldpassword")  <>  objrs("password") Then
					strErrMsg = "Errore:  Vecchia passord non corretta"
			ElseIf request("password1") <> request("password2")	Then									
'			password1 and 2 don't match
					strErrMsg = "Errore:  le nuove password inserite non sono uguali"
			ElseIf Len(Trim(request("password1"))) < 3 or Len(Trim(request("password1"))) > 10 Then
'			wrong len			
					strErrMsg = "Errore:  verificare la lunghezza della password (min. 3, max 10)"
			End If																	
%>
          <td><img src="images/icons/22x22/S_M_ERRO.gif" width="22" height="22">&nbsp;</td>
          <td width="100%" align="center"> 
            <p align="center"><%=strErrMsg%></p></td>
<%


		Else
%>        
          <td><img src="images/icons/22x22/S_M_INFO.gif" width="22" height="22" hspace="10"></td>
          <td width="100%"> 
            <p align="left">Inserire una password di almeno tre caratteri alfanumerici 
              e non pi&ugrave; lunga di dieci caratteri</p></td>
<%
	End If
%>




        </tr>
      </table>
        <form name="form1" method="post" action="change-password.asp">
        <table width="50%" border="0" align="center" cellpadding="0" cellspacing="0" class="TabellaForm">
          <tr> 
            <th nowrap>Vecchia password:</th>
            <td><input name="oldpassword" type="password" class="FormInput" id="oldpassword" size="12" maxlength="10"></td>
          </tr>
          <tr>
            <th nowrap>&nbsp;</th>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <th width="20%" nowrap>Nuova Password:</th>
            <td> <input name="password1" type="password" class="FormInput" id="password1" size="12" maxlength="10"> 
            </td>
          </tr>
          <tr> 
            <th nowrap>Conferma password:</th>
            <td><input name="password2" type="password" class="FormInput" id="password2" size="12" maxlength="10"></td>
          </tr>
        </table>
        <br>
        <table width="50%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
    <td><input name="update" type="submit" class="FormButtont" id="update" value="Aggiorna">
              &nbsp;
              <input name="cancel" type="submit" class="FormButtont" id="cancel" value="Annulla"></td>
  </tr>
</table>
      </form>
	</td>
    <!-- InstanceEndEditable --></tr>
</table>
</body>
<!-- InstanceEnd --></html>
